/*
 * @Description: 文件及简介
 * @Author: Cary
 * @Date: 2019-11-15 16:23:23
 * @FilePath: \excel-to-jsone:\work\node-project\cc-tools\main.js
 */
const pkg = require('./package.json')
const inquirer = require('inquirer')
const program = require('commander')
const chalk = require('chalk')
const toolsInfo = require('./src/utils/info')

import packages from './src/index'

console.log('packages', packages)

console.log(chalk.yellow('欢迎使用 cc-tools 快捷工具箱'))
console.log(chalk.green(toolsInfo()))

program
  .name("cc-tools")
  .usage("[global options] command")

for (const iterator in packages) {
  if (packages[iterator]) {
    packages[iterator].install(program)
  }
}

program
.version(pkg.version)
.description(pkg.description)
.parse(process.argv)

// 未知命令会报错
program.on('command:*', function () {
  console.error('Invalid command: %s\nSee --help for a list of available commands.', program.args.join(' '))
  process.exit(1)
})
